<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/common/header.jsp"%>

<script src="<c:url value="/js/ext/examples.js"/>"
	type="text/javascript"></script>
<link rel="stylesheet" type="text/css"
	href="<c:url value="/js/ext/css/examples.css"/>" />

<script type="text/javascript">

Ext.onReady(function(){

    // --------------- master form -------------------
    var masterFrom_fileType = new Ext.form.ComboBox({
        name: 'fileType',
        hiddenName: 'fileType',
        fieldLabel: '文件类型',
        typeAhead: true,
        triggerAction: 'all',
        lazyRender: true,
        mode: 'local',
        store: new Ext.data.ArrayStore({
            id: 'key',
            fields: [ 'key', 'value'],
            data: [
                [ '1', 'txt'],
                [ '3', 'csv'],
                [ '5', 'xls']
            ]
        }),
        valueField: 'key',
        displayField: 'value'
    });

    var masterFrom = new Ext.form.FormPanel({
        region:'center',
        height:150,
        title: '用户批量导入',
        buttonAlign:'center',
        bodyStyle: 'padding:5px',
        frame: true,
        fileUpload:true,
        layout: 'fit',
        items: [{
            items: [
                    {
                        layout: 'form',
                        labelWidth: 100,
                        defaultType: 'textfield',
                        defaults: {
                            width: 180,
                            msgTarget: 'side'
                        },
                        items: [
                            {
                                xtype: 'textfield',
                                name: 'file',
                                inputType: 'file',
                                fieldLabel: '请选择文件'
                            }
                        ]
                    }
                ]
        }],
        buttons: [
            {
                text: '导入',
                handler: function(){
                    if(masterFrom.getForm().isValid()){
                        masterFrom.getForm().submit({
                            url: '<c:url value="/portal/userInfo/fileImport.do" />',
                            waitTitle: '请等待',
                            waitMsg: '正在处理数据...',
                            timeout: 10,
                            failure:function(form,action){            
			                    Ext.MessageBox.hide();    
			                    Ext.MessageBox.alert('警告', '操作失败。',action.result.msg);   
			                },
                            success: function(form, action){
                                function ok(){
                                    masterFrom.getForm().loadRecord(action.result);                                            
                                }
                                Ext.Msg.alert('提示', '操作成功。', ok);
                            }
                        });
                    }
                }
            }
        ]
    });

  
    // --------------- viewport --------------------

    var viewport = new Ext.Viewport({
        layout: 'border',
        border: false,
        items: [
          masterFrom
        ]
    });

  
});
</script>
<%@ include file="/WEB-INF/views/common/footer.jsp"%>
